<template>
	<view class="cart-container" v-if="cart.length!==0">
		<!-- 收获地址 -->
		<view class="address">
			<my-address></my-address>
		</view>
		<view class="cart-title">
			<!-- 左侧图标 -->
			<uni-icons type="shop" size="18"></uni-icons>

			<!-- 右侧文本 -->
			<text class="cart-title-text">购物车</text>
		</view>
		<uni-swipe-action>
			<block v-for="(goods,i) in cart" :key="i">
			<uni-swipe-action-item :right-options="options" @click="swiperItemClick(goods)">
				<my-goods :item="goods" :showRadio="true" :showNumber="true"   @radio-change="radioHandler" @number-change="numberHandler"></my-goods>
			</uni-swipe-action-item>
			</block>
		</uni-swipe-action>
		<my_settle></my_settle>
	</view>
	<!-- 购物车空空如也 -->
	<view class="empty-cart" v-else>
		<image src="/static/购物车空空如也.png"></image>
	</view>
</template>

<script>
	import tarbar_badge from '../../mixins/tarbar_badge';
	import {mapState,mapMutations} from 'vuex'
	export default {
		mixins:[tarbar_badge],
		data() {
			return {
				options:[{
					text:'删除',
					style:{
						backgroundColor:'#C00000',
						"disableScroll":true,
								"app-plus":{
									"bounce":"none"
								}
					}
				}]
			};
		},
		computed:{
			...mapState('my_cart',['cart'])
		},
		methods:{
			...mapMutations('my_cart',['updateState','updateCount','removeGoodsId']),
			radioHandler(e){
				this.updateState(e)
			},
			numberHandler(e){
				this.updateCount(e)
			},
			swiperItemClick(goods){
				this.removeGoodsId(goods.goods_id)
			}
		}
	}
</script>

<style lang="scss">
	.cart-container{
		padding-bottom:50px ;
	}
	.cart-title{
		height: 40px;
		display: flex;
		align-items: center;
		padding-left: 5px;
		border-bottom: 1px solid #efefef;
		.cart-title-text{
			margin-left: 10px;
			font-size: 12px;
			font-family: 宋体;
		}
	}
	.empty-cart{
		display: flex;
		align-items: center;
		flex-direction: column;
		padding-top: 150px;
		image{
			width: 153.00px;
			height: 144.00px;
		}
	}
</style>
